package pl.mdziedzic.unittests;

import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class LastDaySeleniumSamples {
	
	private WebDriver driver;

	@Before
	public void setUp() {
		driver = new FirefoxDriver();	
	}
	
	@Test
	public void shouldPressArrowDownKey() throws InterruptedException {
		// given
		driver.get("http://allegro.pl");
		
		WebElement searchBox = driver.findElement(By.id("string"));
		searchBox.sendKeys("Samsu");

		TimeUnit.SECONDS.sleep(1);

		// when
		searchBox.sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ENTER);
	}
	
	@Test
	public void shouldGoForwardBackward() {
		// given
		driver.get("http://gazeta.pl");
		driver.get("http://onet.pl");

		// when
		driver.navigate().back();
		driver.navigate().forward();
		driver.navigate().refresh();
	}

}
